﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
using TM.DAL;
using TM.Objects.DTO;
using TM.Objects;
namespace TM.Rules.Web
{
    public partial class RuleResults : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                PopulateRuleCombo();
                
                dtpDate.SelectedDayStyle.BackColor = System.Drawing.Color.Blue;
                dtpDate.SelectedDate = DateTime.Now;
                dtpDate.TodaysDate = DateTime.Now;
            }
        }
        private void BindData()
        {


            List<TMStockEnt> ruleResults = new List<TMStockEnt>();
            int selectedrule =int.Parse (ddlRules.SelectedItem.Value);
            ruleResults = DalManager.GetRuleResults(dtpDate.SelectedDate.Equals(DateTime.MinValue) ? DateTime.Now : dtpDate.SelectedDate, 0, selectedrule);

            //grdStock.DataSource = ruleResults;
            //grdStock.DataBind();

            GV_ExpandRow.DataSource = ruleResults;
            GV_ExpandRow.DataBind();
        }

        void PopulateRuleCombo()
        {
            List<TMRule> rules = new List<TMRule>();
           rules =  DalManager.GetRules("STOCK");
           ddlRules.DataSource = rules;
           ddlRules.DataTextField = "RuleName";
           ddlRules.DataValueField = "RuleId";
           ddlRules.DataBind();
        }

        protected void btnShow_Click(object sender, EventArgs e)
        {
            BindData();
        }
    }
}